#ifndef OCT_TREE_AABB
#define OCT_TREE_AABB

#include <vector>

#include <glm/glm.hpp>
#include "utils.h"

class Mesh;

struct AABB
{
	bool intersect(Ray r) const;
	bool intersectTriangle(glm::vec3 p0, glm::vec3 p1, glm::vec3 p2) const;

	glm::vec3 min_;
	glm::vec3 max_;
};

// octree节点结构
class OctNodeAABB
{
public:
	OctNodeAABB(
		OctNodeAABB* parent,
		int depth,
		Mesh* mesh,
		glm::vec3 aabb_min,
		glm::vec3 aabb_max);
	~OctNodeAABB();

	bool intersect(IntersectionData* id, Ray r) const;

protected:
	Mesh* mesh_;
	AABB aabb_;
	std::vector<unsigned int> triangle_indices_;

	OctNodeAABB* children_[8]; // 子节点

};

class OctTreeAABB : public OctNodeAABB
{
public:
	OctTreeAABB(Mesh* mesh);
	~OctTreeAABB();
private:
};

#endif